#include "Utils.hh"
#include "BankSystem.hh"
#include "Account.hh"
#include "5_ShowAccountMenu.hh"
using namespace BankSystem;

// 客户菜单
void showCustomerMenu(BankSystem::BankSystem& bankSystem, const std::shared_ptr<Customer>& customer) {
    while (true) {
        
        system("clear");
        
        auto savingsAccount = customer->getSavingsAccount();
        auto checkingAccount = customer->getCheckingAccount();
        
        std::cout << "===== Customer: " << customer->getName() << " =====" << std::endl;
        std::cout << "This customer has the following accounts:\n" << std::endl;
        
        std::cout << "1. Savings Account: " << savingsAccount->getAccountId() << std::endl;
        std::cout << "   Balance: " << Utils::formatCurrency(savingsAccount->getBalance()) << "\n" << std::endl;
        
        std::cout << "2. Checking Account: " << checkingAccount->getAccountId() << std::endl;
        std::cout << "   Balance: " << Utils::formatCurrency(checkingAccount->getBalance()) << "\n" << std::endl;
        
        std::cout << "Options:" << std::endl;
        std::cout << "1. Access Savings Account" << std::endl;
        std::cout << "2. Access Checking Account" << std::endl;
        std::cout << "3. View all transactions for this customer" << std::endl;
        std::cout << "4. Generate customer report" << std::endl;
        std::cout << "5. Return to main menu" << std::endl;
        std::cout << "\nPlease choose: ";
        
        int choice;
        std::cin >> choice;
        clearInputBuffer();
        
        switch (choice) {
            case 1:
                showAccountMenu(bankSystem, savingsAccount);
                break;
            case 2:
                showAccountMenu(bankSystem, checkingAccount);
                break;
            case 3:
                system("clear");
                customer->viewAllTransactions();
                waitForEnter();
                break;
            case 4:
                customer->generateReport();
                waitForEnter();
                break;
            case 5:
                return;
            default:
                std::cout << "Invalid choice. Please try again." << std::endl;
                waitForEnter();
        }
    }
}